; NLS
;
;
;
FALSE    EQU 0
TRUE     EQU 1
CR       EQU $8D
;
;
; "IF" STATEMENT EQUATES
;
EQ       EQU "="
NE       EQU "#"
GT       EQU ">"
LT       EQU "<"
GE       EQU ">"|"="*256
LE       EQU "<"|"="*256
;
;
;
;
;
;
;
; SPEED/ASM ENTRY POINTS
;
;
;
; NOTE: THE EQUATE OF PUTC MUST
; BE CHANGED IF YOU RELOCATE
; SPEED/ASM TO SOME LOCATION
; OTHER THAN $7800
;
PUTC     EQU $7000
GETC     EQU PUTC+3
SAGL     EQU GETC+3          ;FOR USE BY S/A ONLY- SEE DOC.
SAPC     EQU SAGL+3          ; "   "   "  "   "     "   "
HOME     EQU SAPC+3          ;HOME AND CLEAR
READLN   EQU HOME+3
INIT     EQU READLN+3
FOR      EQU INIT+3
FOR0     EQU FOR+3
NEXT     EQU FOR0+3
IFI      EQU NEXT+3
IFI0     EQU IFI+3
IFS      EQU IFI0+3
IFS0     EQU IFS+3
MOVE     EQU IFS0+3
LOAD     EQU MOVE+3
MOVS     EQU LOAD+3
LDSTR    EQU MOVS+3
PRINT    EQU LDSTR+3
PRTSTR   EQU PRINT+3
PRTINT   EQU PRTSTR+3
RDSTR    EQU PRTINT+3
RDINT    EQU RDSTR+3
ONXGOTO  EQU RDINT+3
CASE     EQU ONXGOTO+3
CASEI    EQU CASE+3
INSET    EQU CASEI+3
NOTINSET EQU INSET+3
ABS      EQU NOTINSET+3
NEG      EQU ABS+3
MUL      EQU NEG+3
DIV      EQU MUL+3
MOD      EQU DIV+3
RND      EQU MOD+3
SUBSTR   EQU RND+3
INDEX    EQU SUBSTR+3
LENGTH   EQU INDEX+3
CONCAT   EQU LENGTH+3
GETWZPG  EQU CONCAT+3        ;USED BY SPEED/ASM
RDFP     EQU GETWZPG+3
PRTE     EQU RDFP+3
PRTF     EQU PRTE+3
FADD     EQU PRTF+3
FSUB     EQU FADD+3
FMUL     EQU FSUB+3
FDIV     EQU FMUL+3
FLT      EQU FDIV+3
FIX      EQU FLT+3
FNEG     EQU FIX+3
FADDTN   EQU FNEG+3
FSUBTN   EQU FADDTN+3
FTIMES   EQU FSUBTN+3
FINTO    EQU FTIMES+3
IFF      EQU FINTO+3
MOVFP    EQU IFF+3
;
;
;
;
         JSR INIT
;
F1.5LP:
         JSR HOME
         JSR PRINT
         BYT "Testing the SPEED/ASM floating",CR
         BYT "point routines:",CR,CR,CR
         BYT "Enter 1.5:",0
         JSR READLN
         JSR RDFP
         ADR F1.5
         BVS F1.5LP
         JSR YOUENTER
         JSR PRTF
         ADR F1.5
         JSR OTHERWSE
         JSR PRTE
         ADR F1.5
;
FM1.5LP:
         JSR PRINT
         BYT CR,CR
         BYT "Enter -1.5:",0
         JSR READLN
         JSR RDFP
         ADR FM1.5
         BVS FM1.5LP
         JSR YOUENTER
         JSR PRTF
         ADR FM1.5
         JSR OTHERWSE
         JSR PRTE
         ADR FM1.5
;
;
F5E10LP:
         JSR PRINT
         BYT CR,CR
         BYT "Enter 500000:",0
         JSR READLN
         JSR RDFP
         ADR F500000
         BVS F5E10LP
         JSR YOUENTER
         JSR PRTF
         ADR F500000
         JSR OTHERWSE
         JSR PRTE
         ADR F500000
;
;
FM5E5LP  JSR PRINT
         BYT CR,CR
         BYT "Enter -500000:",0
         JSR READLN
         JSR RDFP
         ADR FM500000
         BVS FM5E5LP
         JSR YOUENTER
         JSR PRTF
         ADR FM500000
         JSR OTHERWSE
         JSR PRTE
         ADR FM500000
;
;
F0LP     JSR PRINT
         BYT CR,CR
         BYT "Enter 0:",0
         JSR READLN
         JSR RDFP
         ADR F0
         BVS F0LP
         JSR YOUENTER
         JSR PRTF
         ADR F0
         JSR OTHERWSE
         JSR PRTE
         ADR F0
;
F2LP     JSR PRINT
         BYT CR,CR
         BYT "Enter 2:",0
         JSR READLN
         JSR RDFP
         ADR F2
         BVS F2LP
         JSR YOUENTER
         JSR PRTF
         ADR F2
         JSR OTHERWSE
         JSR PRTE
         ADR F2
;
FM2LP    JSR PRINT
         BYT CR,CR
         BYT "Enter -2:",0
         JSR READLN
         JSR RDFP
         ADR FM2
         BVS FM2LP
         JSR YOUENTER
         JSR PRTF
         ADR FM2
         JSR OTHERWSE
         JSR PRTE
         ADR FM2
;
F2.1LP   JSR PRINT
         BYT CR,CR
         BYT "Enter 2.1:",0
         JSR READLN
         JSR RDFP
         ADR F2.1
         BVS F2.1LP
         JSR YOUENTER
         JSR PRTF
         ADR F2.1
         JSR OTHERWSE
         JSR PRTE
         ADR F2.1
;
FM2.1LP  JSR PRINT
         BYT CR,CR
         BYT "Enter -2.1:",0
         JSR READLN
         JSR RDFP
         ADR FM2.1
         BVS FM2.1LP
         JSR YOUENTER
         JSR PRTF
         ADR FM2.1
         JSR OTHERWSE
         JSR PRTE
         ADR FM2.1
;
FM1.9LP  JSR PRINT
         BYT CR,CR
         BYT "Enter 1.9:",0
         JSR READLN
         JSR RDFP
         ADR F1.9
         BVS FM1.9LP
         JSR YOUENTER
         JSR PRTF
         ADR F1.9
         JSR OTHERWSE
         JSR PRTE
         ADR F1.9
;
F5EM1LP  JSR PRINT
         BYT CR,CR
         BYT "Enter .5:",0
         JSR READLN
         JSR RDFP
         ADR F5EM1
         BVS F5EM1LP
         JSR YOUENTER
         JSR PRTF
         ADR F5EM1
         JSR OTHERWSE
         JSR PRTE
         ADR F5EM1
;
;
         JSR GETRTN
;
;
         JSR PRINT
         BYT "Testing RDFP, PRTF, and PRTE:",CR,CR
         BYT "Enter 55:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 55.55:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter -55:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter -55.55:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5E5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5 E5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5E 5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5 E 5:",0
         JSR GETVAR
;
         JSR PRINT
         BYT "Enter 5.E5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5. E5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5.E 5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5. E 5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5.0E5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5.0 E5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5.0E 5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5.0 E 5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter -5E5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5E-5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5E -5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter -5E-5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5E+5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5E +5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter -5E+5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 5.:",0
         JSR GETVAR
;
         JSR PRINT
         BYT "Enter .5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 0.5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter -0.5:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter -.5:",0
         JSR GETVAR
;
;
         JSR GETRTN
         JSR PRINT
         BYT "Testing RDFP error handling",CR
         BYT "the following should all return errors:",CR,CR
;
         BYT "Enter #.1: ",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 1.#: ",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter #:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 1E38:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 1E-38:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 1D40:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter +1E+10:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 1E-+10:",0
         JSR GETVAR
;
;
         JSR PRINT
         BYT "Enter 1.1.1E10:",0
         JSR GETVAR
;
;
         JSR GETRTN
;
;
         JSR PRINT
         BYT "Testing the FADD routine:",CR,CR
         BYT "1.5+1.5= ",0
         JSR FADD
         ADR F1.5,F1.5,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"2.1+1.9= ",0
         JSR FADD
         ADR F2.1,F1.9,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"500000+(-1.5)= ",0
         JSR FADD
         ADR F500000,FM1.5,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"500000+1.5= ",0
         JSR FADD
         ADR F500000,F1.5,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"0+0.5= ",0
         JSR FADD
         ADR F0,F5EM1,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR GETRTN
;
;
         JSR PRINT
         BYT "Testing the FSUB routine:",CR,CR
;
         BYT "500000-500000= ",0
         JSR FSUB
         ADR F500000,F500000,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"2.1-1.9= ",0
         JSR FSUB
         ADR F2.1,F1.9,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"0.5-(-1.5)= ",0
         JSR FSUB
         ADR F5EM1,FM1.5,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"2-0= ",0
         JSR FSUB
         ADR F2,F0,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR GETRTN
;
;
         JSR PRINT
         BYT "Testing the FMUL routine:",CR,CR
         BYT "1.5*2= ",0
         JSR FMUL
         ADR F1.5,F2,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"-2.1*1.9= ",0
         JSR FMUL
         ADR FM2.1,F1.9,FVAR
         JSR PRTF
         ADR FVAR
;
;
         JSR PRINT
         BYT CR,CR,"(-2.1)*(-2)= ",0
         JSR FMUL
         ADR FM2.1,FM2,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR
         BYT "2*500000= ",0
         JSR FMUL
         ADR F2,F500000,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR
         BYT "0.5*500000= ",0
         JSR FMUL
         ADR F500000,F5EM1,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"500000*0= ",0
         JSR FMUL
         ADR F500000,F0,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"Enter 1E37:",0
         JSR READLN
         JSR RDFP
         ADR F1E37
;
         JSR PRINT
         BYT CR,CR,"Testing FMUL error handling:",CR,CR
         BYT "1E37*500000= ",0
         JSR FMUL
         ADR F1E37,F500000,FVAR
         BVS >0
         JSR PRINT
         BYT CR,"FMUL didn't return an error!",CR,0
         JMP >1
;
^0       JSR PRINT
         BYT CR,"FMUL properly returned an error",CR,0
;
^1       JSR PRINT
         BYT "2*2= ",0
         JSR FMUL
         ADR F2,F2,FVAR
         BVC >0
         JSR PRINT
         BYT CR,"Uh-oh, FMUL returned an error",CR,0
         JMP >1
;
^0       JSR PRINT
         BYT "4",CR,"FMUL returned no error",CR,0
;
^1       JSR GETRTN
;
;
         JSR PRINT
         BYT "Testing the FDIV routine:",CR,CR
         BYT "500000/500000= ",0
         JSR FDIV
         ADR F500000,F500000,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"2/0.5= ",0
         JSR FDIV
         ADR F2,F5EM1,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,"0.5/2= ",0
         JSR FDIV
         ADR F5EM1,F2,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR
         BYT "500000/(-2)= ",0
         JSR FDIV
         ADR F500000,FM2,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR
         BYT "2/500000= ",0
         JSR FDIV
         ADR F2,F500000,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR
         BYT "(-2.1)/(-2)= ",0
         JSR FDIV
         ADR FM2.1,FM2,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR
         BYT "Testing FDIV's error handling",CR,CR
         BYT "1E37/0.000004= ",0
         JSR FDIV
         ADR F2,F500000,FVAR
         JSR FDIV
         ADR F1E37,FVAR,FVAR
         BVS >0
         JSR PRINT
         BYT CR
         BYT "FDIV didn't return an error",CR,0
         JMP >1
;
^0       JSR PRINT
         BYT CR
         BYT "FDIV properly returned an error",CR,0
;
;
^1       JSR PRINT
         BYT CR
         BYT "1.5 / 0 = ",0
         JSR FDIV
         ADR F1.5,F0,FVAR
         BCS >0
         JSR PRINT
         BYT CR
         BYT "FDIV didn't return an error",CR,0
         JMP >1
;
^0       JSR PRINT
         BYT CR,"FDIV properly returned an error",CR,0
;
^1       JSR GETRTN
;
         JSR PRINT
         BYT "That's all folks...",CR,0
         RTS 
;
;
;
;
GETVAR   JSR READLN
         JSR RDFP
         ADR FVAR
         BVC >0
         JSR PRINT
         BYT CR,"RDFP returned an error",CR,0
         RTS 
;
^0       JSR PRTF
         ADR FVAR
         JSR PRINT
         BYT ";  ",0
         JSR PRTE
         ADR FVAR
         JSR PRINT
         BYT CR,CR,0
         RTS 
;
;
;
GETRTN   JSR PRINT
         BYT CR,CR
         BYT "(Press return to contine):",0
         JSR READLN
         JMP HOME
;
;
;
YOUENTER JSR PRINT
         BYT CR
         BYT "You entered:",0
         RTS 
;
OTHERWSE JSR PRINT
         BYT CR
         BYT "which is also: ",0
         RTS 
;
;
F1.5     DFS 8,0
FM1.5    DFS 8,0
F500000  DFS 8,0
FM500000 DFS 8,0
F0       DFS 8,0
F2       DFS 8,0
FM2      DFS 8,0
F2.1     DFS 8,0
FM2.1    DFS 8,0
F1.9     DFS 8,0
F5EM1    DFS 8,0
F1E37    DFS 8,0
FVAR     DFS 8,0
         END 